package person.wend.javalearnexample.util;

import java.util.Locale;
import java.util.ResourceBundle;

public class ResourceBundleExample {

    public static void main(String[] args) {
        // 设置当前语言环境为英文（美国）
        Locale locale1 = new Locale("en", "US");
        // 根据语言环境加载资源文件
        ResourceBundle bundle1 = ResourceBundle.getBundle("Messages", locale1);
        System.out.println(bundle1.getString("greeting"));

        // 设置当前语言环境为中文（中国）
        Locale locale2 = new Locale("zh", "CN");
        ResourceBundle bundle2 = ResourceBundle.getBundle("Messages", locale2);
        System.out.println(bundle2.getString("greeting"));
    }
}
